//
//  ZYPopLayerRequestFactory.m
//  DesignMode
//
//  Created by wangzhipan on 2024/12/5.
//

#import "ZYPopLayerRequestFactory.h"
#import "ZYPopLayerManager.h"
#import "ZYPopLayerRule.h"
#import "ZYPopTimerRequest.h"
#import "ZYPopLayerRequest.h"

@implementation ZYPopLayerRequestFactory
+ (id<IPopLayerRequest>)createRequestOfPopLayerId:(NSString *)popLayerId
                                         isManual:(BOOL)isManual
                                        showBlock:(nonnull PopLayerShowCmd)showBlock
                                       closeBlock:(nonnull PopLayerCloseCmd)closeBlock
                                   interruptBlock:(nullable PopLayerInterruptCmd)interruptBlock
                                        resumeCmd:(nullable PopLayerResumeCmd)resumeBlock
{
    ZYPopLayerRule *rule = [[ZYPopLayerManager sharedInstance] findRuleOfPopLayerId:popLayerId];
    if (rule.duration > 0) {
        return [[ZYPopTimerRequest alloc] initWithPopLayerId:popLayerId
                                                    isManual:isManual
                                                   showBlock:showBlock
                                                  closeBlock:closeBlock
                                              interruptBlock:interruptBlock
                                                   resumeCmd:resumeBlock];
    }
    return [[ZYPopLayerRequest alloc] initWithPopLayerId:popLayerId
                                                isManual:isManual
                                               showBlock:showBlock
                                              closeBlock:closeBlock
                                          interruptBlock:interruptBlock
                                               resumeCmd:resumeBlock];;
}
@end
